package org.example.struct.array;

/**
 * @author liyishan
 * @date 2024/8/8 09:38
 * @apiNote
 */

public class Test00693HasAlternatingBits {
    public boolean hasAlternatingBits(int n) {
        int prev = n % 2;
        n /= 2;
        while (n != 0) {
            int cur = n % 2;
            if (cur == prev) {
                return false;
            }
            prev = cur;
            n /= 2;
        }
        return true;
    }
}
